#!/bin/bash -e

function finish {
  echo -e "\nExiting..."
  kill $WEBPACK_PID
  kill $SERVER_PID
}

make clean
DRAGGABLE_DEBUG=true webpack --watch --devtool inline-source-map &
WEBPACK_PID=$!

# # Run a static server and run the example in it.
$BIN/static-server . &
SERVER_PID=$!

# Open browser
node -e "\
  var open = require('open'); open('http://localhost:9080/example'); \
"

# Kill webpack on exit.
trap finish EXIT

wait
